package com.example.spider.jsoup;

import org.apache.commons.io.FileUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.File;
import java.io.IOException;

public class jsoupString {
    public static void main(String[] args) throws Exception {

        //读取数据加载为字符串
        String ht = FileUtils.readFileToString(new File("D:\\ideaWorkSpace\\spider\\src\\main\\resources\\jsoupString.html"));
        //解析字符串
        Document doc = Jsoup.parse(ht);
        //提取数据
        String title = doc.getElementsByTag("title").first().text();
        System.out.println(title);

    }
}
